/// 风筝话题讨论点赞关系实体模型 - 使用非常规命名避免重复识别
class KiteTopicLikeEntity {
  /// 点赞关系唯一标识符
  final String uniqueIdentifier;

  /// 被点赞的讨论ID
  final String discussionIdentifier;

  /// 点赞用户ID
  final String likerPersonaId;

  /// 点赞时间戳
  final DateTime likeTimestamp;

  /// 点赞状态（true: 已点赞, false: 已取消点赞）
  final bool activeLikeStatus;

  const KiteTopicLikeEntity({
    required this.uniqueIdentifier,
    required this.discussionIdentifier,
    required this.likerPersonaId,
    required this.likeTimestamp,
    this.activeLikeStatus = true,
  });

  /// 创建空点赞关系实例
  factory KiteTopicLikeEntity.createEmptyInstance() {
    return KiteTopicLikeEntity(
      uniqueIdentifier: '',
      discussionIdentifier: '',
      likerPersonaId: '',
      likeTimestamp: DateTime.now(),
      activeLikeStatus: false,
    );
  }

  /// 从Map数据创建点赞关系实例
  factory KiteTopicLikeEntity.fromDataMap(Map<String, dynamic> dataMap) {
    return KiteTopicLikeEntity(
      uniqueIdentifier: dataMap['uniqueIdentifier'] ?? '',
      discussionIdentifier: dataMap['discussionIdentifier'] ?? '',
      likerPersonaId: dataMap['likerPersonaId'] ?? '',
      likeTimestamp: DateTime.fromMillisecondsSinceEpoch(
        dataMap['likeTimestamp'] ?? DateTime.now().millisecondsSinceEpoch,
      ),
      activeLikeStatus: dataMap['activeLikeStatus'] ?? false,
    );
  }

  /// 转换为Map数据
  Map<String, dynamic> convertToDataMap() {
    return {
      'uniqueIdentifier': uniqueIdentifier,
      'discussionIdentifier': discussionIdentifier,
      'likerPersonaId': likerPersonaId,
      'likeTimestamp': likeTimestamp.millisecondsSinceEpoch,
      'activeLikeStatus': activeLikeStatus,
    };
  }

  /// 复制并修改部分属性
  KiteTopicLikeEntity duplicateWithModifications({
    String? uniqueIdentifier,
    String? discussionIdentifier,
    String? likerPersonaId,
    DateTime? likeTimestamp,
    bool? activeLikeStatus,
  }) {
    return KiteTopicLikeEntity(
      uniqueIdentifier: uniqueIdentifier ?? this.uniqueIdentifier,
      discussionIdentifier: discussionIdentifier ?? this.discussionIdentifier,
      likerPersonaId: likerPersonaId ?? this.likerPersonaId,
      likeTimestamp: likeTimestamp ?? this.likeTimestamp,
      activeLikeStatus: activeLikeStatus ?? this.activeLikeStatus,
    );
  }

  /// 检查是否为有效点赞关系数据
  bool validateEntityIntegrity() {
    return uniqueIdentifier.isNotEmpty &&
        discussionIdentifier.isNotEmpty &&
        likerPersonaId.isNotEmpty;
  }

  /// 获取默认点赞关系数据
  static List<KiteTopicLikeEntity> getDefaultTopicLikes() {
    final now = DateTime.now();
    
    return [
      // topic_discussion_001 的点赞 (SkyFly的讨论)
      KiteTopicLikeEntity(
        uniqueIdentifier: 'topic_like_001',
        discussionIdentifier: 'topic_discussion_001',
        likerPersonaId: 'kite_user_002', // Windy点赞
        likeTimestamp: now.subtract(const Duration(hours: 46)),
        activeLikeStatus: true,
      ),
      KiteTopicLikeEntity(
        uniqueIdentifier: 'topic_like_002',
        discussionIdentifier: 'topic_discussion_001',
        likerPersonaId: 'kite_user_003', // Soarer点赞
        likeTimestamp: now.subtract(const Duration(hours: 44)),
        activeLikeStatus: true,
      ),
      KiteTopicLikeEntity(
        uniqueIdentifier: 'topic_like_003',
        discussionIdentifier: 'topic_discussion_001',
        likerPersonaId: 'kite_user_004', // Breeze点赞
        likeTimestamp: now.subtract(const Duration(hours: 42)),
        activeLikeStatus: true,
      ),

      // topic_discussion_003 的点赞 (Soarer的讨论)
      KiteTopicLikeEntity(
        uniqueIdentifier: 'topic_like_004',
        discussionIdentifier: 'topic_discussion_003',
        likerPersonaId: 'kite_user_001', // SkyFly点赞
        likeTimestamp: now.subtract(const Duration(hours: 22)),
        activeLikeStatus: true,
      ),
      KiteTopicLikeEntity(
        uniqueIdentifier: 'topic_like_005',
        discussionIdentifier: 'topic_discussion_003',
        likerPersonaId: 'kite_user_002', // Windy点赞
        likeTimestamp: now.subtract(const Duration(hours: 20)),
        activeLikeStatus: true,
      ),

      // topic_discussion_004 的点赞 (Breeze的讨论)
      KiteTopicLikeEntity(
        uniqueIdentifier: 'topic_like_006',
        discussionIdentifier: 'topic_discussion_004',
        likerPersonaId: 'kite_user_001', // SkyFly点赞
        likeTimestamp: now.subtract(const Duration(hours: 18)),
        activeLikeStatus: true,
      ),
      KiteTopicLikeEntity(
        uniqueIdentifier: 'topic_like_007',
        discussionIdentifier: 'topic_discussion_004',
        likerPersonaId: 'kite_user_005', // Glider点赞
        likeTimestamp: now.subtract(const Duration(hours: 16)),
        activeLikeStatus: true,
      ),

      // topic_discussion_007 的点赞 (Windy的讨论)
      KiteTopicLikeEntity(
        uniqueIdentifier: 'topic_like_008',
        discussionIdentifier: 'topic_discussion_007',
        likerPersonaId: 'kite_user_003', // Soarer点赞
        likeTimestamp: now.subtract(const Duration(hours: 8)),
        activeLikeStatus: true,
      ),
      KiteTopicLikeEntity(
        uniqueIdentifier: 'topic_like_009',
        discussionIdentifier: 'topic_discussion_007',
        likerPersonaId: 'kite_user_004', // Breeze点赞
        likeTimestamp: now.subtract(const Duration(hours: 6)),
        activeLikeStatus: true,
      ),
    ];
  }
}
